#include<iostream>
#include "AStar.h"
using namespace std;
int main()
{
	int xSize, ySize;
	int obsAccount;
	Vec2 begin, end;
	AStarNode** gridData;
	Vec2 obsTemp;
	cin >> ySize >> xSize;
	cin >> obsAccount;
	gridData = new AStarNode*[ySize];
	for (int i = 0; i < ySize; i++)
	{
		gridData[i] = new AStarNode[xSize];
		for (int k = 0; k < xSize; k++)
		{
			gridData[i][k].position.y = i;
			gridData[i][k].position.x = k;
		}
	}
	for (int i = 0; i < obsAccount; i++)
	{
		cin >> obsTemp.y >> obsTemp.x;
		gridData[obsTemp.y-1][obsTemp.x-1].weight = INFINITY;
	}
	for (int i = 0; i < ySize; i++)
	{
		for (int j = 0; j < xSize; j++)
		{
			cout.width(10);
			cout << gridData[i][j].weight << " ";
		}
		cout << endl;
	}
	AStar aStar(gridData, xSize, ySize);
	cin >> begin.y >> begin.x;
	cin >> end.y >> end.x;
	auto result=aStar.getPath(&gridData[begin.y-1][begin.x-1], &gridData[end.y-1][end.x-1]);
	for (auto i : result)
		cout << "("<<i->position.y<<","<<i->position.x<<")" << endl;
	cout << "end procces!" << endl;
	return 0;
}